package com.lbn.monitor.app.account;

import android.text.TextUtils;

import com.free.framework.business.NetSubscriber;
import com.lbn.monitor.App;
import com.lbn.monitor.api.AppHost;
import com.lbn.monitor.base.AppBasePresenter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李炳南
 * @date 2017/3/6
 */
public class CpwPresenter extends AppBasePresenter<ICpwView> {


    public void pwd(String oldPassword,String newPassword,String confirmPassword){

        if(TextUtils.isEmpty(oldPassword)){
            getView().showToast("旧密码不能为空");
            return;
        }

        if(TextUtils.isEmpty(newPassword)){
            getView().showToast("新密码不能为空");
            return;
        }

        if(TextUtils.isEmpty(confirmPassword)){
            getView().showToast("确认密码不能为空");
            return;
        }

        if(!confirmPassword.equals(newPassword)){
            getView().showToast("两次密码输入不一致");
            return;
        }

        subscribeNetwork(AppHost.getApi().pwd(App.getUser().getId(),oldPassword,newPassword), new NetSubscriber(getView(),true) {
            @Override
            public void onNext(Object o) {
                getView().onSucceed();
            }
        });
    }
}
